#include<bits/stdc++.h>
using namespace std;
int t,n,m,L,V;
int v[100500],a[100500],d[100500],p[100500],l,r,ans,mid,ans1,cnt,cnt2;
int cnt3,ncnt[100500],np[100500];
bool flag[100500];
struct aaa{
    int v,id;
}pcnt[100500];
bool cmp(aaa a,aaa b){
    return a.v<b.v;
}
bool check(int x,int v,int a,int d){
    if(x>L)return false;
    if(x<d)return false;
    if(v*v+2*a*(x-d)<=0)return false;
    //cout<<v<<" "<<a<<" "<<d<<" "<<x<<" "<<sqrt(v*v+2*a*(x-d))<<endl;
    return v*v+2*a*(x-d)>V*V;
}
int main(){
    freopen("detect.in","r",stdin);
    freopen("detect.out","w",stdout);
    cin>>t;
    while(t--){
        memset(flag,0,100500);
        cin>>n>>m>>L>>V;
        for(int i=0;i<n;i++)cin>>d[i]>>v[i]>>a[i];
        for(int i=0;i<m;i++)cin>>p[i];
        sort(p,p+m);
        cnt=0;
        cnt3=0;
        for(int i=0;i<n;i++){
            //cout<<v[i]<<" "<<a[i]<<" "<<d[i]<<V<<endl;
            l=lower_bound(p,p+m,d[i])-p;
            if(l>0){
                if(p[l-1]==d[i])l--;
            }
            cnt2=l;
            r=m-1,ans=-1;
            while(l<=r){
                mid=l+r>>1;
                if(check(p[mid],v[i],a[i],d[i])){
                    if(a[i]>=0)ans=mid,r=mid-1;
                    else ans=mid,l=mid+1;
                }
                else{
                    if(a[i]>=0)l=mid+1;
                    else r=mid-1;
                }
            }
            np[i]=ans;
            if(ans!=-1){
                //cout<<i<<" "<<ans<<" "<<a[i]<<endl;
                cnt++;
                if(a[i]>=0){
                    pcnt[ans+1].v++;
                }
                else{
                    pcnt[cnt2+1].v++;
                    pcnt[ans+2].v--;
                }
            }
        }
        for(int i=1;i<=m;i++)pcnt[i].v+=pcnt[i-1].v,pcnt[i].id=i;
        sort(pcnt+1,pcnt+m+1,cmp);
        for(int i=1;i<=m;i++)pcnt[i].v+=pcnt[i-1].v;
        for(int i=1;i<=m;i++){
            if(pcnt[i].v==0)cnt3++;
            else{
                if(pcnt[m].v-pcnt[i].v<cnt)break;
                cnt3++;
            }
        }
        cout<<cnt<<" "<<cnt3<<endl;
    }
    return 0;
}
